#!/usr/bin/env python
# -*- coding:utf-8 -*-
from django import forms

from stark.service.stark import StarkConfig, get_choice_text, Option, StarkModelForm

from rbac.utils.encrypt import md5
from task import models


class UserModelForm(StarkModelForm):
    class Meta:
        model = models.UserInfo
        fields = '__all__'

    def clean_password(self):
        return md5(self.cleaned_data['password'])


class UserInfoHandler(StarkConfig):
    list_display = ['nickname', 'email', 'depart', get_choice_text('level', '级别')]

    model_form_class = UserModelForm
